<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //声明对象
        // let person = {}
        let person = new Object()

        let goods = {
            sname: '小米10',
            num: '2324352',
            weight: '0.55kg',
            address: '中国大陆',
            //方法 对象里面叫方法，对象外面叫函数
            telephone: function (x, y) {
                console.log('我可以打电话')
                return x + y
            }
        }
        goods.sname = '小米10plus'
        goods.color = '粉色'
        // console.log(goods.sname, goods.num, goods.weight, goods.address)
        console.log(goods['sname'], goods['num'], goods['weight'], goods['address'])

        //调用对象的方法
        console.log(goods.telephone(1, 2))

        //for(let k in 对象名) {} 遍历对象goods[k]取对象的值 一般不用来遍历数组,因为k是字符串类型，不是数组下标
        let arr = ['red', 'pink', 'blue']

        for (let k in arr) {
            console.log(k)
            console.log(arr[k])
        }
        console.log('-------------------')

        for (let k in goods){
            console.log(goods[k])
        }

        console.log('-------------------')
        //打印数组对象
        let students = [
            {name:'小明',age : 14, gender:'男', hometown:'河北省'},
            {name:'小米',age : 15, gender:'女', hometown:'河北省'},
            {name:'小李',age : 14, gender:'男', hometown:'河北省'},
            {name:'小红',age : 18, gender:'女', hometown:'河北省'}            
        ]

        for (let i = 0; i < students.length; i++){
            for (let k in students[i]){
                console.log( students[i][k])
            }
        }




    </script>
</body>

</html>